﻿using EmoneyWeiXinEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using EmoneyWeiXinCommon;

namespace EmoneyWeiXinDAL
{
    public class UserPhoneBindDAL
    {
        public int Insert(UserPhoneBindEntity entity)
        {
            string sql = "proc_AddVipUser";
            SqlParameter[] paras = 
                  {
                  new SqlParameter("@weixinId",entity.weixinId),
                  new SqlParameter("@openId",entity.openId),
                  new SqlParameter("@phoneHideMid",entity.phoneHideMid),
                  new SqlParameter("@phoneMd5",entity.phoneMd5),
                  new SqlParameter("@phoneDefEncode",entity.phoneDefEncode),
                  new SqlParameter("@QQNumber",entity.QQNumber),
                  new SqlParameter("@groupid",30),
                  new SqlParameter("@template_id",Config.KaitongmodelId)
                 };
            return SQLHelper.ExecuteNonQuery(Config.EmoneyWeiXin, System.Data.CommandType.StoredProcedure, sql, paras);


        }
        /// <summary>
        /// 判断是否已经绑定
        /// </summary>
        /// <returns></returns>
        public bool IsBind(string openId, string weixinId)
        {
            string sql = "SELECT * FROM UserPhoneBind with(nolock)";
            return true;
        }

        public UserPhoneBindEntity GetOne(string openId, string weixinId)
        {
            string sql = "SELECT * FROM UserPhoneBind with(nolock) where openId=@openId AND weixinId=@weixinId";
            SqlParameter[] paras = 
            {
              new SqlParameter("@openId",openId),
              new SqlParameter("@weixinId",weixinId)
            };
            return SQLHelper.GetDataByColumns<UserPhoneBindEntity>(Config.EmoneyWeiXin, sql, paras);
        }


    }
}
